package com.at.source3;

import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.connector.file.src.FileSource;
import org.apache.flink.connector.file.src.reader.TextLineInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author huangchao E-mail:fengquan8866@163.com
 * @version 创建时间：2024/9/23 21:05
 */
public class FileSourceDemo2 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        FileSource<String> fileSource = FileSource
                .forRecordStreamFormat(
                        new TextLineInputFormat(),
                        new Path("input/word.txt"))
                .build();
        env
                .fromSource(fileSource, WatermarkStrategy.noWatermarks(), "fileSource")
                .print();
        env.execute();
    }
}
/**
 * 新的Source写法：
 *   env.fromSource(Source.实现类，Watermark，名字）
 */
